package com.kushuigu;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Aspect
public class MyEval {
    @Pointcut("execution(* com.kushuigu.service.AccountService.*(*))")
    public void pt() {

    }

    @Around("pt()")
    public Object aroundAccountService(ProceedingJoinPoint point) throws Throwable {
        Object[] args = point.getArgs();
        System.out.println(Arrays.toString(args));
        long start = System.currentTimeMillis();
        Signature signature = point.getSignature();
        Object o = null;
        args[0]=1;
        for (int i = 0; i < 100; i++) {
            o = point.proceed(args);
            System.out.println(o.toString());
        }
        long end = System.currentTimeMillis();
        System.out.println(signature.getName() + "time" + (end - start) + "ms");
        return o;
    }
}
